﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GeneralDFS.DataEntity.Nodes;

namespace GeneralDFS.DataEntity.IO
{
    /// <summary>
    /// this class indicate the one block with dataNodeIDs
    /// </summary>
    [Serializable]
    public class LocatedBlock
    {
        public FileBlockMetaData FileBlockMetaData { get; set; }

        public DataNodeID[] DataNodeIds { get; set; }

        public LocatedBlock()
        {
            FileBlockMetaData=new FileBlockMetaData();
        }

        public LocatedBlock(FileBlockInfo fileBlockInfo)
        {
            if (fileBlockInfo == null) throw new ArgumentNullException("fileBlockInfo");
            FileBlockMetaData = fileBlockInfo;

            DataNodeIds = new DataNodeID[fileBlockInfo.NumNodes()];
            for (var i = 0; i < DataNodeIds.Length; i++)
            {
                DataNodeIds[i] = fileBlockInfo.GetDataNodeInfo(0);
            }
        }
    }
}